package com.mop.core.es.bean.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mop.core.es.bean.common.Imgs;
import java.util.LinkedList;
import java.util.List;

/**
 * @author lemon
 * @ClassName CommonBeanUtils
 * @desc
 * @Date 2019/3/1 19:07
 * @Version 1.0
 **/
public class CommonBeanUtils {

    public static List<Imgs> convertToImgs(String imgsStr) {
        List<Imgs> imgsList = new LinkedList<Imgs>();
        JSONArray jsonArray = JSON.parseArray(imgsStr);
        for (Object obj : jsonArray) {
            JSONObject imgObj = (JSONObject) obj;
            String imgwidth = imgObj.getString("imgwidth");
            String imgheight = imgObj.getString("imgheight");
            String src = imgObj.getString("src");

            imgsList.add(new Imgs(imgwidth, imgheight, src));
        }
        return imgsList;
    }
}
